<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.List" %>
<%@ page import="javax.jdo.PersistenceManager" %>
<%@ page import="com.google.appengine.api.users.User" %>
<%@ page import="com.google.appengine.api.users.UserService" %>
<%@ page import="com.google.appengine.api.users.UserServiceFactory" %>
<%@ page import="com.readytocloud.r2cSoonSite.SmallNote" %>
<%@ page import="com.readytocloud.r2cSoonSite.PMF" %>
<%@ page import="com.readytocloud.r2cSoonSite.NoteRepository" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>Ready to Cloud! Technology Management, Cloud Computing, Entrepreneurship, Solution Provider, Dallas, Puerto Rico</title>
	    <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.0.0/build/cssreset/reset-min.css">
	    <link type="text/css" rel="stylesheet" href="/static/css/main.css">
	    <link rel="shortcut icon" href="http://comingsoonpage.s3.amazonaws.com/favicon_blue.ico">
	    <meta name="msvalidate.01" content="4CA640C7E6ED60014904ECEA56EA1B60">
	    <meta name="y_key" content="76be6c93d33da719">
	    <meta name="google-site-verification" content="elkfN9O7traowYvxoYkAKha2IePC-EYArOA6qC_PFGY">
	</head>
	<body>
		<div id="wrap">
			<div id="loginControl">
				<%	UserService userService = UserServiceFactory.getUserService();
					User user = userService.getCurrentUser();
					if(user != null)	{	%>
				<p>Hello, <%= user.getNickname() %>!(You can
				<a href="<%= userService.createLogoutURL(request.getRequestURI()) %>">sign out</a>.)</p>
				<%
		    		} else {
				%>
				<p>Hello!
				<a href="<%= userService.createLoginURL(request.getRequestURI()) %>">Sign in</a>
				to include your name with greetings you post.</p>
				<%
		    		}
				%>
			</div>
			<div id="messageContainer">
			<div id="messagesFromUsers">
			<%	NoteRepository noteRepo = new NoteRepository();
				List<SmallNote> notes = noteRepo.GetNotes();
				if(notes.isEmpty()){	%>		
				<p>The Note Section has no notes.</p>
			<%
    			} else {
        	for (SmallNote g : notes) {
            if (g.getAuthor() == null) {
			%>
				<p>An anonymous person wrote:</p>
			<%
            	} else {
			%>
				<p><b><%= g.getAuthor().getNickname() %></b> wrote on:</p>
			<%
             	}
			%>
				<blockquote id="userMessage"><%= g.getContent() %></blockquote>
			<%
        		} 		} noteRepo.Close();  		
			%>
			</div>
			<div id="userMessageForm">
			<form action="/sign" method="post">
				<div><textarea name="content" rows="3" cols="60"></textarea></div>
	      		<div><input type="submit" value="Post Greeting" /></div>
	    	</form>
			</div>
			</div>
		</div>
	</body>
</html>